title="order-detail"
url = '/:slug|orderdetail-\d+.html$'
layout="default"

[session]
security = "user"
redirect = "account/login"
==

use Jason\Ccshop\Models\OrderStatus;
use GuzzleHttp\Client;

function onStart() {
header("Content-type: text/html; charset=utf-8");
$userid_login = $this['user']['attributes']['id'];
$slugArr = explode('-', str_replace('.html', '', $this->param('slug')));
$sn = $slugArr['1'];
$this['sn'] = $sn;

$order = App::make('Jason\Ccshop\Controllers\Orders')->orderDetail($sn);
$userid_order = $order['attributes']['uid'];
if($order == null){
return redirect('/account/login.html');
}
if($userid_order != $userid_login){
return redirect('/account/login.html');
}
$this['orderStatusCode'] = $order->order_status->code;

$this['order'] = $order;
//dump($order);
}
==

<div class="address_content">
	<!-- breadcrumbs -->
	<div class="breadcrumbs">
		<div class="container">
			<ul>
				<li class="fl" ><a href="/">FASHIONDM</a></li>
				<li class="fl" >お買物履歴詳細</li>
			</ul>
		</div>
	</div>
	<!-- breadcrumbs end -->
	<div class="orderCont">
		<div class="container">
			<h2 class="pageHead1">お買物履歴詳細</h2>
			<div class="ov dashboardBox">
				<div class="fl d_sidemenus">
					{% partial 'account/left-bar' %}
				</div>
				<div class="fr d_main" style="width: 790px;">
					<div class="main-ttl">お買物履歴詳細</div>
					<div class="detailBox orderBox">
						<div class="detail_date">
							<div class="history-status">{{ ('jason.ccshop::lang.order.status.' ~ orderStatusCode)|trans }}</div>
							<div class="data-header">
								<div class="date orderday">注文日：{{ order.created_at }}</div>
							</div>
							<table class="table table-bordered table-striped" width="100%">
					            <tbody>
					              <tr class="first odd">
					                <td colspan="4"><b>ご注文詳細：</b></td>
					              </tr>
					              <tr class="first odd">
					                <td>ご注文番号</td>
					                <td>{{ order.sn }}</td>
					                <td>注文時間</td>
					                <td>{{ order.created_at }}</td>
					              </tr>
					              <tr class="first odd">
					                  <td>決済方法</td>
					                  <td>{{ order.payment.name }}</td>
					                  <td>配送方法</td>
					                  <td>{{ order.shippingmethod.name }}</td>
					              </tr>
					              <tr class="first odd">
					                <td>商品金額</td>
					                <td>{{ order.products_price|formatPriceNotRate }}</td>
					                <td>送料</td>
					                <td>{{ order.freight|formatPriceNotRate }}</td>
					              </tr>
					              <tr class="first odd">
					                  <td>割引</td>
					                  <td>{% for od in order.discount %}
					                      {% if od.type == 'points' %}

					                      ポイント割引
					                      <span>{{ od.price|format }}</span>

					                      {% elseif od.type == 'promoAmount' %}

					                      <span>{{ od.price|format }}</span>

					                      {% elseif od.type == 'coupon' %}
					                      クーポン割引
					                      <span>{{ od.price|format }}</span>
					                      {% endif %}
					                      {% endfor %}
					                  </td>
					                  <td>合計金額</td>
					                  <td>{{ order.total_price|formatPriceNotRate }}</td>
					              </tr>
					              <tr class="first odd">
					                <td colspan="4"><b>連絡先：</b></td>
					              </tr>
					              <tr class="first odd">
					                <td>注文者</td>
					                <td>{{ order.firstname }}{{ order.lastname }}</td>
					                <td>メールアドレス</td>
					                <td>{{ order.email }}</td>
					              </tr>
					              <tr class="first odd">
					                <td>電話番号</td>
					                <td>{{ order.phonenumber }}</td>
					                <td>郵便番号</td>
					                <td>{{ order.postcode }}</td>
					              </tr>
					              <tr class="first odd">
					                <td>国</td>
					                <td>{{ order.country.name }}</td>
					                <td>都道府県</td>
					                <td>{{ order.state.name }}</td>
					              </tr>
					              <tr class="first odd">
					                <td>都市</td>
					                <td>{{ order.city }}</td>
					                <td>住所</td>
					                <td>{{ order.address }}</td>
					              </tr>
					            </tbody>
							</table>

							<p class="cautions">
								※コンビニ前払い、Pay-easy（ATM・ネットバンキング払い）の場合は、「<a href="#settlement" class="colrBlue" shape="rect">お支払い方法</a>」でお客様番号などをご確認ください。
							</p>
						<table class="table table-bordered" style="margin-top:10px;" align="center">
			              <thead>
			              <tr class="first odd">
			                <td colspan="6"><strong>ご注文商品リスト：</strong></td>
			              </tr>

			              <tr class="first odd">
			                <td >商品画像</td>
			                <td >商品名</td>
			                <td  >属性</td>
			                <td  >単価</td>
			                <td  >数量</td>
			                <td  >小計</td>
			                {% if order.status_id == 5  %}
			                <td  >レビュー</td>
			                {% endif %}
			              </tr>
			              </thead>

			              <tbody>
			              {% for m, orderproduct in order.products %}
			              {% set condition = { 'id': orderproduct.product_id } %}
			              {% set product = catalog.product(condition) %}

			              <tr class="first odd">
			                <td width="96">
			                  <a href="{{ product.url }}">
			                    <img src="{{ product.getMainThumb(75, 100 ) }}" alt="{{ orderproduct.name }}">
			                  </a>
			                </td>
			                <td ><a href="{{ product.url }}">{{ orderproduct.name }}</a></td>
			                <td >
			                  {% for keyoption, option in orderproduct.options %}
			                  {{keyoption}}:
			                  {% for key, optionvalue in option %}
			                  {{optionvalue}}
			                  {% endfor %}
			                  <br>
			                  {% endfor %}
			                </td>
			                <td >{{ orderproduct.price|formatPriceNotRate }}</td>
			                <td >{{ orderproduct.qty }}</td>
			                <td >{{ (orderproduct.price * orderproduct.qty)|formatPriceNotRate }}</td>
			                {% if order.status_id == 5  %}
			                <td >
			                  <a href="#scrollDuck" class="btn_viw_od" id="btn_viw_od" data-product-id="{{ orderproduct.product_id }}" style="margin-bottom:10px;">レビュー</a>
			                </td>
			                {% endif %}
			              </tr>
			              {% endfor %}
			              <tr>
			                <td class="textAlign" colspan="6" style="text-align:right;">
			                  {% partial 'account/order-detail-status-operation' order=order %}
			              </td>
			              </tr>
			              </tbody>
			            </table>
							{% if order.cart %}
							<table class="purchase-result" width="100%">

								<tbody>
								<tr>
									<th>数量合計</th>
									<td>{{ order.cart.totalQty }}点</td>
								</tr>
								<tr>
									<th>商品合計<span>（税抜）</span></th>
									<td>{{ order.cart.sumProductPrice|formatPrice }}</td>
								</tr>
								{% if order.cart.promoAmount %}
								<tr>
									<th>値引き</th>
									<td>－{{ order.cart.promoAmount|formatPrice }}</td>
								</tr>
								{% endif %}
								<tr>
									<th>送料</th>
									<td>{{ order.cart.freight|formatPrice }}</td>
								</tr>

								<tr>
									<th>消費税合計</th>
									<td>{{ order.cart.tax|formatPrice }}</td>
								</tr>
								<tr>
									<th style="font-weight:bold;">合計</th>
									<td style="font-weight:bold;">{{ order.cart.totalPrice|formatPrice }}</td>
								</tr>
								{% if order.cart.points %}
								<tr>
									<th>ご利用ポイント</th>
									<td>{{ order.cart.points }}ポイント<br clear="none"><span>（－{{ order.cart.points.amount|format }}）</span>
									</td>
								</tr>
								{% endif %}
								<tr>
									<th>ご請求金額</th>
									<td>{{ order.cart.totalPrice |formatPrice }}</td>
								</tr>

								</tbody>
							</table>
							{% endif %}
							<div>
							</div>
						</div>
						<div class="detail_txt">
							<div class="users-informations goInquiryBox">
								<div class="ttl">お問い合わせ</div>
								<div class="onBigBtn goInquiryBox_show">
									<img src="{{ 'assets/img/btn-inquiry-open.png'|theme }}" alt="" class="mr-auto">
								</div>
								<div class="goInquiryBox">
									<div class="new-inquiry">
										<p class="lead">ご注文内容についてご要望他、お問い合わせがございましたら、ご入力の上、送信してください。</p>
										<div class="skin-minimal">
											<table width="100%">
												<tbody>
												<tr>
													<th colspan="1" rowspan="1" >お問い合わせ項目</th>
													<td colspan="1" rowspan="1" class="icon" ><img height="20" alt="必須" width="44" src="{{ 'assets/img/icon-must.gif'|theme }}"></td>
													<td colspan="1" rowspan="1" class="input-element">
														<div class="iradio_box">
															<label>
																<div class="iradio_minimal">
																	<input type="radio" name="indexForm1" value="1" title="性別" style="">
																	<ins class="iCheck-helper" style=""></ins>
																</div>商品について
															</label>
															<label>
																<div class="iradio_minimal">
																	<input type="radio" name="indexForm1" value="1" title="性別" style="">
																	<ins class="iCheck-helper" style=""></ins>
																</div>ご注文について
															</label>
															<label>
																<div class="iradio_minimal">
																	<input type="radio" name="indexForm1" value="1" title="性別" style="">
																	<ins class="iCheck-helper" style=""></ins>
																</div>配送について
															</label>
														</div>
													</td>
												</tr>
												<tr>
													<th colspan="1" rowspan="1" >お問い合わせ内容</th>
													<td colspan="1" rowspan="1" class="icon" ><img height="20" alt="必須" width="44" src="{{ 'assets/img/icon-must.gif'|theme }}"></td>
													<td colspan="1" rowspan="1" class="input-element">
														<textarea name="" class="registInquiryBody" title="お問い合わせ内容" placeholder="さらに問い合わせる" rows="10"></textarea>
														<p class="ex">（4000文字以内）</p>
													</td>
												</tr>

												</tbody>
											</table>
											<div class="onBigBtn">
												<a href=""><img src="{{ 'assets/img/btn-inquiry-send.png'|theme }}" alt=""></a>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
{% partial 'account/order-cancel-pop' %}